import { createApp } from 'vue'
import '@/assets/styles/index.css'
import App from './App.vue'
import router from './router'
import store from './store'
import 'lib-flexible'
import QMP from '@/plugins/qmp-ui'
import { DevConfig, nativeHandler, judgeSys } from 'qmp-native'

const app = createApp(App)

// 生产环境不显示调试器
// if (process.env.QMP_EVN !== 'production') {
//   const Vconsole = require('vconsole')
//   new Vconsole()
// }

// 添加全局方法
app.config.globalProperties.$nativeHandler = nativeHandler
app.config.globalProperties.$judgeSys = judgeSys

if (process.env.QMP_EVN === 'development') {
  DevConfig.useDefaultData = true // 开发环境调用原生方法时，使用是否使用默认数据
  // 开发环境默认数据配置
  DevConfig.defaultData = {
    '': {
      token: 'Bearer 2fdf1091-cd4e-4433-a969-17d15fa14e08'
    },
    // nativeHandler('getBaseInfo') 接口在测试环境返回的数据
    getBaseInfo: {
      account: 'yuhao1',
      userName: '土豪'
    },
    // 调用原生其他接口 返回的数据
    default: {
      property1: 'value1',
      property2: 'value2'
    }
  }
}

// 注册qmp-ui组件
const qmpComponents = [...QMP.components]
qmpComponents.forEach((i) => app.use(i))

app.use(store).use(router).mount('#app')
